package com.ittest.service.store.impl;

import com.ittest.domain.store. Traveller;
import com.ittest.factory.MapperFactory;
import com.ittest.mapper.store. TravellerMapper;
import com.ittest.service.store.TravellerService;
import com.ittest.utils.TransactionUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class TravellerServiceImpl implements TravellerService {
    @Override
    public List<Traveller> findByOrderId(String id) {
        SqlSession sqlSession = null;
        List<Traveller> list = null;
        try {
            //获取sqlSession
            sqlSession = MapperFactory.getSqlSession();
            //获取Mapper代理对象
             TravellerMapper travellerMapper = MapperFactory.getMapper(sqlSession,TravellerMapper.class);
            list = travellerMapper.findByOrderId(id);

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            //释放资源
            if (sqlSession!=null) {
                TransactionUtil.close(sqlSession);
            }
        }
        return list;
    }
}
